package com.gogowan.agroenterprise.widget.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

public abstract class MyBaseAdapater extends BaseAdapter {

    private List<?> list;
    public abstract List<?> getList();
    public abstract Context ItemContext();
    public abstract int ItemLayout();
    public abstract Object setHoulder(View view);
    public abstract void OnItem(Object o, int position);
    @Override
    public int getCount() {
        list=getList();
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Object o=null;
        if (convertView==null){
            convertView= LayoutInflater.from(ItemContext()).inflate(ItemLayout(),null);
            o=setHoulder(convertView);
            convertView.setTag(o);
        }else {
           o=(Object) convertView.getTag();
        }
        OnItem(o,position);
        return convertView;
    }
    public interface onItemViewClickListener{
        void onItemViewpositioni(int position);
    }
}
